#pragma once
#include "uvlogpublic.h"

namespace Log
{

enum class Print {
    console = 0x1,
    file    = 0x2,
    both    = 0x3
};

bool UVLOG_API open(Print print, uvLogPlus::Level level, const char *pathFileName, bool sync = false);
void UVLOG_API close();

void UVLOG_API print(uvLogPlus::Level level, const char *file, int line, const char *func, const char *fmt, ...);

#if defined(_WIN32) || defined(WIN32)
#define debug(fmt, ...)         print(uvLogPlus::Level::Debug,   __FILE__, __LINE__, __FUNCTION__, fmt, ##__VA_ARGS__)
#define info(fmt, ...)          print(uvLogPlus::Level::Info,    __FILE__, __LINE__, __FUNCTION__, fmt, ##__VA_ARGS__)
#define warning(fmt, ...)       print(uvLogPlus::Level::Warn,    __FILE__, __LINE__, __FUNCTION__, fmt, ##__VA_ARGS__)
#define error(fmt, ...)         print(uvLogPlus::Level::Error,   __FILE__, __LINE__, __FUNCTION__, fmt, ##__VA_ARGS__)
#else
#define debug(fmt, args...)         print(uvLogPlus::Level::Debug,   __FILE__, __LINE__, __FUNCTION__, fmt, ## args)
#define info(fmt, args...)          print(uvLogPlus::Level::Info,    __FILE__, __LINE__, __FUNCTION__, fmt, ## args)
#define warning(fmt, args...)       print(uvLogPlus::Level::Warn,    __FILE__, __LINE__, __FUNCTION__, fmt, ## args)
#define error(fmt, args...)         print(uvLogPlus::Level::Error,   __FILE__, __LINE__, __FUNCTION__, fmt, ## args)
#endif
}
